<cfparam name="resetFilters" default="false">
<cfparam name="showStats" default="false" />
<cfset isFiltered = false />
<cfset queryParams = StructNew() />

<!--- Program years --->
<cfif NOT IsDefined("client.gds.programYears") or resetFilters>
	<cfset client.gds.programYears = request.currentProgramYear>
<cfelseif IsDefined("filterProgramYears")>
	<cfset client.gds.programYears = filterProgramYears>
</cfif>
<cfif client.gds.programYears neq request.currentProgramYear>
	<cfset isFiltered = true />
	<cfset queryParams.programYears = client.gds.programYears />
<cfelse>
	<cfset queryParams.programYears = request.currentProgramYear />
</cfif>
<!--- Match Round --->
<cfif NOT IsDefined("client.gds.matchRound") or resetFilters>
	<cfset client.gds.matchRound = "Current">
<cfelseif IsDefined("filterMatchRound")>
	<cfset client.gds.matchRound = filterMatchRound>
</cfif>
<cfif client.gds.matchRound neq "Current">
	<cfset isFiltered = true />
	<cfset queryParams.matchRound = client.gds.matchRound />
<cfelse>
	<cfset queryParams.matchRound = "Current" />
</cfif>
<!--- Organizations --->
<cfif NOT IsDefined("client.gds.organizationIDs") or resetFilters>
	<cfset client.gds.organizationIDs = "All">
<cfelseif IsDefined("filterOrganizationIDs")>
	<cfset client.gds.organizationIDs = filterOrganizationIDs>
</cfif>
<cfif client.gds.organizationIDs neq "All">
	<cfset isFiltered = true />
	<cfset queryParams.organizationIDs = client.gds.organizationIDs />
	<cfset filterRegionIDs = "All" />
</cfif>
<!--- Regions --->
<cfif IsUserInRole("Super User")>
	<cfif NOT IsDefined("client.gds.regionIDs") or resetFilters>
		<cfset client.gds.regionIDs = "All">
	<cfelseif IsDefined("filterRegionIDs")>
		<cfset client.gds.regionIDs = filterRegionIDs>
	</cfif>
<cfelseif IsUserInRole("Regional Admin")>
	<cfset client.gds.regionIDs = request.authUser.regionID>
</cfif>
<cfif client.gds.regionIDs neq "All">
	<cfset isFiltered = true />
	<cfset queryParams.regionIDs = client.gds.regionIDs />
</cfif>
<!--- score ranges --->
<cfif NOT IsDefined("client.gds.rangeStartingScore") or resetFilters>
	<cfset client.gds.rangeStartingScore = 100 />
<cfelseif IsDefined("filterRangeStartingScore")>
	<cfset client.gds.rangeStartingScore = filterRangeStartingScore />
</cfif>
<cfif client.gds.rangeStartingScore neq 100>
	<cfset isFiltered = true />
	<cfset rangeEndingScore = client.gds.rangeStartingScore + 19 />
	<cfset queryParams.scoreRange = client.gds.rangeStartingScore />
	<cfset queryParams.scoreRange = ListAppend(queryParams.scoreRange, rangeEndingScore) />
<cfelse>
	<cfset queryParams.scoreRange = "100,100" />
</cfif>

<cfwddx action="cfml2wddx" input="#queryParams#" output="client.gds.queryParamsWDDX" />

<cfscript>
	base = new assets.calgrants.com.Base();
	organizationGateway = new assets.calgrants.com.gateway.OrganizationGateway();
	organizations = organizationGateway.query(regionIDs = IIf(IsUserInRole("Regional Admin"), request.authUser.regionID, ""), Organization_ID = IIf(IsUserInRole("Organizer") OR IsUserInRole("Site Contact"), request.authUser.organizationID, ""));
	storedProcedureGateway = new assets.calgrants.com.gateway.StoredProcedureGateway();
	regions = storedProcedureGateway.call("getDistinctRegions");
	gdsGateway = new assets.calgrants.com.gateway.GDSGateway();
	gds = gdsGateway.query(argumentCollection = queryParams);
</cfscript>

<h3>GDS<cfif isFiltered> <small><em>filtered</em></small></cfif></h3>

<cfoutput>

	<div class="row-fluid" style="margin-bottom: 10px;">
		<div class="span12">
			<a id="filterLink" href="##" class="btn" onclick="toggleFilter('filter')">Show filters</a>
			<div class="btn-group">
				<button class="btn dropdown-toggle" data-toggle="dropdown">Actions</button>
				<button class="btn dropdown-toggle" data-toggle="dropdown"><span class="caret"></span></button>
				<ul class="dropdown-menu">
					<cfif gds.RecordCount gt 0>
						<li><a href="?action=export&collection=gds" target="_new">Export</a></li>
					</cfif>
					<li><a href="?action=export&collection=gdsMatch" target="_new">Export match-ready data</a></li>
					<li><a href="?action=import&collection=gdsMatch" target="_new">Import matched data</a></li>
					<li><a href="?action=scoreGDSMatch" target="_new">Rerun matched data scores</a></li>
					<li><a href="?view=gdsMatchValidation" target="_new">Verify matched data</a></li>
					<li><a href="?view=gdsMatchValidation" target="_new">Migrate matched data</a></li>
				</ul>
			</div>
			<span class="pull-right"><strong>Count:</strong> #gds.RecordCount#</span>
		</div>
	</div>
	
	<cfform name="gdsForm" id="gdsForm" action="#script_name#" method="post">
		<cfinput type="hidden" name="view" value="#view#">
		
		<div id="filter" class="alert alert-info alert-block" style="display: none;">
			<h4>Filters</h4>
			<table cellpadding="6">
				<tr valign="top">
					<td>
						<label>Program Year</label>
						<cfselect name="filterProgramYears" size="1" multiple="false" required="yes" message="Program Year filter is required" style="width: 150px;">
							<cfloop index="y" from="2012" to="#ListFirst(application.currentProgramYear, '-')#">
								<cfset py = "#y#-" & y+1>
								<option value="#py#"<cfif client.gds.programYears eq py> selected</cfif>>#py#</option>
							</cfloop>
						</cfselect>
					</td>
					<td>
						<label>Match Round</label>
						<cfselect name="filterMatchRound" size="7" multiple="true" required="yes" message="Match Round filter is required" style="width: auto;">
							<option value="Current"<cfif client.gds.matchRound eq "Current"> selected</cfif>>Current</option>
							<cfloop index="matchRound" list="1,2,3,4">
								<option value="#matchRound#"<cfif ListFind(client.gds.matchRound, matchRound)> selected</cfif>>#matchRound#</option>
							</cfloop>
						</cfselect>
					</td>
					<cfif IsUserInRole("Super User")>
						<td>
							<label>Region</label>
							<cfselect name="filterRegionIDs" size="7" multiple="true" required="yes" message="Region filter is required" style="width: 150px;">
								<option value="All"<cfif client.gds.regionIDs eq "All"> selected</cfif>>All</option>
								<cfloop query="regions">
									<option value="#Region_ID#"<cfif ListFind(client.gds.regionIDs, Region_ID)> selected</cfif>>#Region_ID#</option>
								</cfloop>
							</cfselect>
						</td>
					</cfif>
					<td>
						<label>Organizations</label>
						<cfselect name="filterOrganizationIDs" size="7" multiple="true" required="yes" message="Organizations filter is required" style="width: auto;">
							<option value="All"<cfif client.gds.organizationIDs eq "All"> selected</cfif>>All</option>
							<cfloop query="organizations">
								<option value="#Organization_ID#"<cfif ListFind(client.gds.organizationIDs, Organization_ID)> selected</cfif>>#Organization# - #City#</option>
							</cfloop>
						</cfselect>
					</td>
					<td>
						<label>Score Range</label>
						<cfselect name="filterRangeStartingScore" size="7" multiple="true" required="yes" message="Score Range filter is required" style="width: 150px;">
							<option value="All"<cfif client.gds.rangeStartingScore eq "All"> selected</cfif>>All</option>
							<cfloop index="startingScore" list="0,20,40,60,80,100">
								<cfset endingScore = startingScore + 19 />
								<cfif startingScore eq 100>
									<cfset endingScore = 100 />
								</cfif>
								<option value="#startingScore#"<cfif ListFind(client.gds.rangeStartingScore, startingScore)> selected</cfif>>#Int(startingScore)#%-#Int(endingScore)#%</option>
							</cfloop>
						</cfselect>
					</td>
					<!--- <td>
						<label>Match Criteria</label>
						<cfselect name="filterMatchCriteria" size="1" required="yes" message="Match Criteria filter is required" style="width: 150px;">
							<!--- <option value="All"<cfif client.gds.matchCriteria eq "All"> selected</cfif>>All</option> --->
							<cfloop list="1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20" index="matchCriteria">
								<option value="#matchCriteria#"<cfif ListFind(client.gds.Match_Criteria, matchCriteria)> selected</cfif>>#matchCriteria#</option>
							</cfloop>
						</cfselect>
					</td>
					<td>
						<label>Verification Action</label>
						<cfselect name="filterProposalValue" size="1" required="yes" message="Proposal Value filter is required" style="width: 150px;">
							<!--- <option value="All"<cfif client.gds.proposalValue eq "All"> selected</cfif>>All</option> --->
							<cfloop list="Match,Review,Unmatch" index="proposalValue">
								<option value="#proposalValue#"<cfif ListFind(client.gds.proposalValue, proposalValue)> selected</cfif>>#proposalValue#</option>
							</cfloop>
						</cfselect>
					</td> --->
				</tr>
				<tr>
					<td colspan="5">
						<button type="submit" class="btn btn-info">Apply</button> <a href="#script_name#?view=#view#&resetFilters=true" class="btn btn-info">Clear</a>
					</td>
				</tr>
			</table>
		</div>
	</cfform>
</cfoutput>

<style>
	div.rec-box {
		min-height: 200px;
	}
	span.highlighted {
		background-color: green;
		color: white;
		
	}
	.ssn-muted {
		color: #CCC;
	}
	span.hl {
		background-color: white;
		color: grey;
	}
	.alert {
		margin-bottom: 0px;
	}

	tbody td.success {
		background-color: #dff0d8;
		color: #468847;
	}
	tbody td.error {
		background-color: #f2dede;
		color: #b94a48;
	}
	tbody td.warning {
		background-color: #fcf8e3;
		color: #c09853;
	}
	tbody td.infos {
		background-color: #d9edf7;
		color: #3a87ad;
	}
	tbody td.info {
		background-color: #eee;
		color: #ccc;
	}
	tbody td.gdsPhone {
		/*padding-top: 20px;*/
	}
	table tbody tr th {width: 200px; !important}
	table tbody td.lengthCell {width: 60px; !important}
	table tbody td.distanceCell {width: 60px; !important}
	table tbody td.scoreCell {width: 60px; !important}
	table tbody td.bonusCell {width: 60px; !important}
</style>

<cfif gds.RecordCount gt 0>
	<script type="text/javascript">
		var unmatchGDS = function(gdsId) {
			$.ajax({
				type: "GET",
				url: "/assets/calgrants/com/API.cfc?method=destroy",
				data: $.param({objType: "GDS", GDS_ID: gdsId}),
				success: function(response) {
					$("#gdsMatch_" + gdsId).slideUp("slow");
				},
				error: function(jqXHR, textStatus, errorThrown) {
					alert("Something went wrong. Please contact the developer");
				}
			});
		}
		var confirmUnmatch = function(gdsId) {
			if (confirm("Are you sure you want to remove this match\?")) {
				unmatchGDS(gdsId);
			}
		}
	</script>
	<div class="container-fluid">
		<cfoutput query="gds" maxrows="100">
			<div class="row-fluid">
				<div class="span9">
					<table class="table table-bordered">
						<thead>
							<th></th>
							<th colspan="2">GDS</th>
							<th colspan="2">Exit Survey</th>
							<th>Excluded</th>
							<th>Match</th>
							<th>Score</th>
							<th>Bonus</th>
						
						<tbody>
							<tr class="rec-row" valign="middle">
								<th>First Name</th>
								<cfif fieldStruct["FirstName"].length gt 0 and fieldStruct["FirstName"].distance eq 0>
									<td colspan="2" class="success">
										#base.titleCase(GDS_First_Name)#
									</td>
								<cfelseif fieldStruct["FirstName"].length gt 0 and fieldStruct["FirstName"].distance gt 0>
									<td colspan="2" class="error">
										#base.titleCase(GDS_First_Name)#
									</td>
								<cfelseif fieldStruct["FirstName"].length eq 0>
									<td colspan="2" class="info">
										No data
									</td>
								</cfif>
								<cfif fieldStruct["FirstName"].length gt 0 and fieldStruct["FirstName"].distance eq 0>
									<td colspan="2" class="success">
										#base.titleCase(Student_First_Name)#
									</td>
								<cfelseif fieldStruct["FirstName"].length gt 0 and fieldStruct["FirstName"].distance gt 0>
									<t colspan="2"d class="error">
										#base.titleCase(Student_First_Name)#
									
								<cfelseif fieldStruct["FirstName"].length eq 0>
									<td colspan="2" class="info">
										No data
									</td>
								</cfif>
								<td class="excludeCell">#YesNoFormat(fieldStruct["FirstName"].exclude)#</td>	
								<td class="matchCell">#YesNoFormat(fieldStruct["FirstName"].match)#</td>
								<td class="scoreCell">#Int(fieldStruct["FirstName"].score)#%</td>		
								<td class="bonusCell">#fieldStruct["FirstName"].bonusPoints#</td>
							</tr>
							<tr class="rec-row">
								<th>Last Name</th>
								<cfif fieldStruct["LastName"].length gt 0 and fieldStruct["LastName"].distance eq 0>
									<td colspan="2" class="success">
										#base.titleCase(GDS_Last_Name)#
									</td>
								<cfelseif fieldStruct["LastName"].length gt 0 and fieldStruct["LastName"].distance gt 0>
									<td colspan="2" class="error">
										#base.titleCase(GDS_Last_Name)#
									</td>
								<cfelseif fieldStruct["LastName"].length eq 0>
									<td colspan="2" class="info">
										No data
									</td>
								</cfif>
								<cfif fieldStruct["LastName"].length gt 0 and fieldStruct["LastName"].distance eq 0>
									<td colspan="2" class="success">
										#base.titleCase(Student_Last_Name)#
									</div>
								<cfelseif fieldStruct["LastName"].length gt 0 and fieldStruct["LastName"].distance gt 0>
									<td colspan="2" class="error">
										#base.titleCase(Student_Last_Name)#
									</td>
								<cfelseif fieldStruct["LastName"].length eq 0>
									<td colspan="2" class="warning">
										No data
									</td>
								</cfif>
								<td class="excludeCell">#YesNoFormat(fieldStruct["LastName"].exclude)#</td>		
								<td class="matchCell">#YesNoFormat(fieldStruct["LastName"].match)#</td>
								<td class="scoreCell">#Int(fieldStruct["LastName"].score)#%</td>
								<td class="bonusCell">#fieldStruct["LastName"].bonusPoints#</td>
							</tr>
							<tr class="rec-row">
								<th>Address</th>
								<cfif fieldStruct["Address"].length gt 0 and fieldStruct["Address"].distance eq 0>
									<td colspan="2" class="success">
										#base.titleCase(GDS_Address)#
									</div>
								<cfelseif fieldStruct["Address"].length gt 0 and fieldStruct["Address"].distance gt 0>
									<td colspan="2" class="error">
										#base.titleCase(GDS_Address)#
									</div>
								<cfelseif fieldStruct["Address"].length eq 0>
									<td colspan="2" class="info">
										No GDS address
									
								</cfif>
								<cfif fieldStruct["Address"].length gt 0 and fieldStruct["Address"].distance eq 0>
									<td colspan="2" class="success">
										#base.titleCase(Student_Address)#
									
								<cfelseif fieldStruct["Address"].length gt 0 and fieldStruct["Address"].distance gt 0>
									<td colspan="2" class="error">
										#base.titleCase(Student_Address)#
									
								<cfelseif fieldStruct["Address"].length eq 0>
									<td colspan="2" class="info">
										No data
									
								</cfif>
								<td class="excludeCell">#YesNoFormat(fieldStruct["Address"].exclude)#</td>	
								<td class="matchCell">#YesNoFormat(fieldStruct["Address"].match)#</td>
								<td class="scoreCell">#Int(fieldStruct["Address"].score)#%</td>			
								<td class="bonusCell">#fieldStruct["Address"].bonusPoints#</td>
							</tr>
							<tr class="rec-row">
								<th>City</th>
								<cfif fieldStruct["City"].length gt 0 and fieldStruct["City"].distance eq 0>
									<td colspan="2" class="success">
										#base.titleCase(GDS_City)#
									</td>
								<cfelseif fieldStruct["City"].length gt 0 and fieldStruct["City"].distance gt 0>
									<td colspan="2" class="error">
										#base.titleCase(GDS_City)#
									</td>
								<cfelseif fieldStruct["City"].length eq 0>
									<td colspan="2" class="info">
										No data
									</td>
								</cfif>
								<cfif fieldStruct["City"].length gt 0 and fieldStruct["City"].distance eq 0>
									<td colspan="2" class="success">
										#base.titleCase(Student_City)#
									</td>
								<cfelseif fieldStruct["City"].length gt 0 and fieldStruct["City"].distance gt 0>
									<td colspan="2" class="error">
										#base.titleCase(Student_City)#
									</td>
								<cfelseif fieldStruct["City"].length eq 0>
									<td colspan="2" class="info">
										No data
									</td>
								</cfif>
								<td class="excludeCell">#YesNoFormat(fieldStruct["City"].exclude)#</td>			
								<td class="matchCell">#YesNoFormat(fieldStruct["City"].match)#</td>		
								<td class="scoreCell">#Int(fieldStruct["City"].score)#%</td>	
								<td class="bonusCell">#fieldStruct["City"].bonusPoints#</td>
							</tr>
							<tr class="rec-row">
								<th>Zip Code</th>
								<cfif fieldStruct["ZipCode"].length gt 0 and fieldStruct["ZipCode"].distance eq 0>
									<td colspan="2" class="success">
										#GDS_Zip_Code#
									</td>
								<cfelseif fieldStruct["ZipCode"].length gt 0 and fieldStruct["ZipCode"].distance gt 0>
									<td colspan="2" class="error">
										#GDS_Zip_Code#
									</td>
								<cfelseif fieldStruct["ZipCode"].length eq 0>
									<td colspan="2" class="info">
										No data
									</td>
								</cfif>
								<cfif fieldStruct["ZipCode"].length gt 0 and fieldStruct["ZipCode"].distance eq 0>
									<td colspan="2" class="success">
										#Student_Zip_Code#
									</td>
								<cfelseif fieldStruct["ZipCode"].length gt 0 and fieldStruct["ZipCode"].distance gt 0>
									<td colspan="2" class="error">
										#Student_Zip_Code#
									</td>
								<cfelseif fieldStruct["ZipCode"].length eq 0>
									<td colspan="2" class="info">
										No data
									</td>
								</cfif>
								<td class="excludeCell">#YesNoFormat(fieldStruct["ZipCode"].exclude)#</td>	
								<td class="matchCell">#YesNoFormat(fieldStruct["ZipCode"].match)#</td>
								<td class="scoreCell">#Int(fieldStruct["ZipCode"].score)#%</td>					
								<td class="bonusCell">#fieldStruct["ZipCode"].bonusPoints#</td>
							</tr>
							<cfif totalStruct.phone eq "Home">
								<tr class="rec-row">
									<th nowrap="nowrap">Home Phone</th>
									<cfif (fieldStruct["Phone1"].length gt 0 and fieldStruct["Phone1"].distance eq 0) OR (fieldStruct["Phone2"].length gt 0 and fieldStruct["Phone2"].distance eq 0)>
										<td colspan="2" class="success gdsPhone">
											#base.formatPhone(GDS_Phone)#
										</td>
									<cfelseif (fieldStruct["Phone1"].length gt 0 and fieldStruct["Phone1"].distance gt 0) OR (fieldStruct["Phone1"].length gt 0 and fieldStruct["Phone2"].distance gt 0)>
										<td colspan="2" class="error gdsPhone">
											#base.formatPhone(GDS_Phone)#
										</td>
									<cfelseif fieldStruct["Phone1"].length eq 0>
										<td colspan="2" class="info gdsPhone">
											#base.formatPhone(GDS_Phone)#
										</td>
									<cfelse>
										<td colspan="2" class="info gdsPhone">
											No data
										</td>
									</cfif>
									<cfif fieldStruct["Phone1"].length gt 0 and fieldStruct["Phone1"].distance eq 0>
										<td colspan="2" class="success">
											#base.formatPhone(Student_Phone1)#
										</td>
									<cfelseif fieldStruct["Phone1"].length gt 0 and fieldStruct["Phone1"].distance gt 0>
										<td colspan="2" class="error">
											#base.formatPhone(Student_Phone1)#
										</td>
									<cfelseif fieldStruct["Phone1"].length eq 0>
										<td colspan="2" class="info">
											No data
										</td>
									</cfif>
									<td class="excludeCell">#YesNoFormat(fieldStruct["Phone1"].exclude)#</td>	
									<td class="matchCell">#YesNoFormat(fieldStruct["Phone1"].match)#</td>	
									<td class="scoreCell">#Int(fieldStruct["Phone1"].score)#%</td>			
									<td class="bonusCell">#fieldStruct["Phone1"].bonusPoints#</td>
								</tr>
							</cfif>
							<cfif totalStruct.phone eq "Cell">
								<tr class="rec-row">
									<th>Cell Phone</th>
									<cfif (fieldStruct["Phone1"].length gt 0 and fieldStruct["Phone1"].distance eq 0) OR (fieldStruct["Phone2"].length gt 0 and fieldStruct["Phone2"].distance eq 0)>
										<td colspan="2" class="success gdsPhone">
											#base.formatPhone(GDS_Phone)#
										</td>
									<cfelseif (fieldStruct["Phone1"].length gt 0 and fieldStruct["Phone1"].distance gt 0) OR (fieldStruct["Phone1"].length gt 0 and fieldStruct["Phone2"].distance gt 0)>
										<td colspan="2" class="error gdsPhone">
											#base.formatPhone(GDS_Phone)#
										</td>
									<cfelseif fieldStruct["Phone1"].length eq 0>
										<td colspan="2" class="info gdsPhone">
											#base.formatPhone(GDS_Phone)#
										</td>
									<cfelse>
										<td colspan="2" class="info gdsPhone">
											No data
										</td>
									</cfif>
									<cfif fieldStruct["Phone2"].length gt 0 and fieldStruct["Phone2"].distance eq 0>
										<td colspan="2" class="success">
											#base.formatPhone(Student_Phone2)#
										</td>
									<cfelseif fieldStruct["Phone2"].length gt 0 and fieldStruct["Phone2"].distance gt 0>
										<td colspan="2" class="error">
											#base.formatPhone(Student_Phone2)#
										</td>
									<cfelseif fieldStruct["Phone2"].length eq 0>
										<td colspan="2" class="info">
											No data
										</td>
									</cfif>
									<td class="excludeCell">#YesNoFormat(fieldStruct["Phone2"].exclude)#</td>	
									<td class="matchCell">#YesNoFormat(fieldStruct["Phone2"].match)#</td>
									<td class="scoreCell">#Int(fieldStruct["Phone2"].score)#%</td>					
									<td class="bonusCell">#fieldStruct["Phone2"].bonusPoints#</td>
								</tr>
							</cfif>
							<tr class="rec-row">
								<th>E-mail</th>
								<cfif fieldStruct["Email"].length gt 0 and fieldStruct["Email"].distance eq 0>
									<td colspan="2" class="success">
										#GDS_Email#
									</td>
								<cfelseif fieldStruct["Email"].length gt 0 and fieldStruct["Email"].distance gt 0>
									<td colspan="2" class="error">
										#GDS_Email#
									</td>
								<cfelseif fieldStruct["Email"].length eq 0>
									<td colspan="2" class="info">
										No data
									</td>
								</cfif>
								<cfif fieldStruct["Email"].length gt 0 and fieldStruct["Email"].distance eq 0>
									<td colspan="2" class="success">
										#Student_Email#
									</td>
								<cfelseif fieldStruct["Email"].length gt 0 and fieldStruct["Email"].distance gt 0>
									<td colspan="2" class="error">
										#Student_Email#
									</td>
								<cfelseif fieldStruct["Email"].length eq 0>
									<td colspan="2" class="info">
										No data
									</td>
								</cfif>
								<td class="excludeCell">#YesNoFormat(fieldStruct["Email"].exclude)#</td>		
								<td class="matchCell">#YesNoFormat(fieldStruct["Email"].match)#</td>
								<td class="scoreCell">#Int(fieldStruct["Email"].score)#%</td>			
								<td class="bonusCell">#fieldStruct["Email"].bonusPoints#</td>
							</tr>
							<tr class="rec-row">
								<th>DOB</th>
								<cfif fieldStruct["DOB"].length gt 0 and fieldStruct["DOB"].distance eq 0>
									<td colspan="2" class="success">
										#GDS_DOB#
									</td>
								<cfelseif fieldStruct["DOB"].length gt 0 and fieldStruct["DOB"].distance gt 0>
									<td colspan="2" class="error">
										#GDS_DOB#
									</td>
								<cfelseif fieldStruct["DOB"].length eq 0>
									<td colspan="2" class="info">
										No data
									</td>
								</cfif>
								<cfif fieldStruct["DOB"].length gt 0 and fieldStruct["DOB"].distance eq 0>
									<td colspan="2" class="success">
										#Student_DOB#
									</td>
								<cfelseif fieldStruct["DOB"].length gt 0 and fieldStruct["DOB"].distance gt 0>
									<td colspan="2" class="error">
										#Student_DOB#
									</td>
								<cfelseif fieldStruct["DOB"].length eq 0>
									<td colspan="2" class="info">
										No data
									</td>
								</cfif>
								<td class="excludeCell">#YesNoFormat(fieldStruct["DOB"].exclude)#</td>
								<td class="matchCell">#YesNoFormat(fieldStruct["DOB"].match)#</td>
								<td class="scoreCell">#Int(fieldStruct["DOB"].score)#%</td>					
								<td class="bonusCell">#fieldStruct["DOB"].bonusPoints#</td>
							</tr>
							<tr class="rec-row">
								<th>SSN (last 4)</th>
								<cfif fieldStruct["SSN"].length gt 0>
									<cfset validSSN = IsValid("ssn", base.formatSSN(GDS_SSN)) />
									<cfif validSSN>
										<cfif fieldStruct["SSN"].distance eq 0>
											<td colspan="2" class="success">
												<span class="ssn-muted">#Left(base.formatSSN(GDS_SSN), 7)#</span>#Right(GDS_SSN, 4)#
											</td>
										<cfelse>
											<td colspan="2" class="error">
												<span class="ssn-muted">#Left(base.formatSSN(GDS_SSN), 7)#</span>#Right(GDS_SSN, 4)#
											</td>
										</cfif>
									<cfelse>
										<cfif fieldStruct["SSN"].distance eq 0>
											<td colspan="2" class="info">
												<span class="ssn-muted">#Left(GDS_SSN, lenSSN - 4)#</span>#Right(GDS_SSN, 4)#
											</td>
										<cfelse>
											<td colspan="2" class="error">
												<span class="ssn-muted">#Left(GDS_SSN, lenSSN - 4)#</span>#Right(GDS_SSN, 4)#
											</td>
										</cfif>
									</cfif>
								<cfelseif fieldStruct["SSN"].length eq 0>
									<td colspan="2" class="info">
										No data
									</td>
								</cfif>
								<cfif fieldStruct["SSN"].length gt 0>
									<cfset validSSN = Len(Student_SSN) eq 4 />
									<cfif validSSN>
										<cfif fieldStruct["SSN"].distance eq 0>
											<td colspan="2" class="success">
												<span class="ssn-muted">######-####-</span>#Student_SSN#
											</td>
										<cfelse>
											<td colspan="2" class="error">
												<span class="ssn-muted">######-####-</span>#Student_SSN#
											</td>
										</cfif>
									<cfelse>
										<cfif fieldStruct["SSN"].distance eq 0>
											<td colspan="2" class="info">
												<span class="ssn-muted">######-####-</span>#Student_SSN#
											</td>
										<cfelse>
											<td colspan="2" class="error">
												<span class="ssn-muted">######-####-</span>#Student_SSN#
											</td>
										</cfif>
									</cfif>
								<cfelseif fieldStruct["SSN"].length eq 0>
									<td colspan="2" class="info">
										No data
									</td>
								</cfif>
								<td class="excludeCell">#YesNoFormat(fieldStruct["SSN"].exclude)#</td>
								<td class="matchCell">#YesNoFormat(fieldStruct["SSN"].match)#</td>	
								<td class="scoreCell">#Int(fieldStruct["SSN"].score)#%</td>				
								<td class="bonusCell">#fieldStruct["SSN"].bonusPoints#</td>
							</tr>
						</tbody>
					</table>
				
				<div class="span3">
					<h1>#Int(IIf(totalStruct.netScore gt 100 and totalStruct.bonusPoints gt 0, DE('99'), totalStruct.netScore))#%</h1>
					<table class="table table-bordered">
						<tr>
							<th>Fields</th>
							<td>#totalStruct.count#</td>
						</tr>
						<tr>
							<th>Perfect Matches</th>
							<td>#totalStruct.matches#</td>
						</tr>
						<tr>
							<th>Excluded Fields</th>
							<td>#totalStruct.exclusions#</td>
						</tr>
						<tr>
							<th>Bonus Percent</th>
							<td>#totalStruct.bonusPoints#</td>
						</tr>
					</table>
					<a href="##" class="btn btn-danger btn-block" onclick="confirmUnmatch(#GDS_ID#); return false;">Unmatch</a>
				</div>
			
		</cfoutput>
	

<cfelse>

	<div class="alert alert-info notFound">No GDS records</div>
	<script type="text/javascript" language="javascript">
	<!--
		$(function() {
			$("#filter").show();
		});
	// -->
	</script>
	
</cfif>

<!--- 
Backups of prior work that has been replaced.  Saved until v0.1 just in case there is an useful tidbit in the code.

Series of data UI preso, early on.
<cfset totalDistance = 0 />
			<cfset totalLen = 0 />
			<cfset totalMatches = 0 />
			<cfset phoneInPlay = 0 />
			<cfif fieldStruct["xxxxx"].lengthFirstName gt 0>
				<cfset totalDistance = totalDistance + distanceFirstName />
				<cfset totalLen = totalLen + lenFirstName />
				<cfset totalMatches = totalMatches + 1 />
			</cfif>
			<cfif fieldStruct["xxxxx"].lengthLastName gt 0>
				<cfset totalDistance = totalDistance + distanceLastName />
				<cfset totalLen = totalLen + lenLastName />
				<cfset totalMatches = totalMatches + 1 />
			</cfif>
			<cfif fieldStruct["xxxxx"].lengthAddress gt 0>
				<cfset totalDistance = totalDistance + distanceAddress />
				<cfset totalLen = totalLen + lenAddress />
				<cfset totalMatches = totalMatches + 1 />
			</cfif>
			<cfif fieldStruct["xxxxx"].lengthCity gt 0>
				<cfset totalDistance = totalDistance + distanceCity />
				<cfset totalLen = totalLen + lenCity />
				<cfset totalMatches = totalMatches + 1 />
			</cfif>
			<cfif fieldStruct["xxxxx"].lengthZipCode gt 0>
				<cfset totalDistance = totalDistance + distanceZipCode />
				<cfset totalLen = totalLen + lenZipCode />
				<cfset totalMatches = totalMatches + 1 />
			</cfif>
			<cfif fieldStruct["xxxxx"].lengthPhone1 gt 0 and fieldStruct["xxxx"].distancePhone1 eq 0>
				<cfset totalDistance = totalDistance + distancePhone1 />
				<cfset totalLen = totalLen + lenPhone1 />
				<cfset totalMatches = totalMatches + 1 />
				<cfset phoneInPlay = 1 />
			<cfelseif fieldStruct["xxxxx"].lengthPhone2 gt 0 and fieldStruct["xxxx"].distancePhone2 eq 0>
				<cfset totalDistance = totalDistance + distancePhone2 />
				<cfset totalLen = totalLen + lenPhone2 />
				<cfset totalMatches = totalMatches + 1 />
				<cfset phoneInPlay = 2 />
			<cfelseif fieldStruct["xxxxx"].lengthPhone1 gt 0 and lenPhone2 gt 0>
				<cfif distancePhone1 lte distancePhone2>
					<cfset totalDistance = totalDistance + distancePhone1 />
					<cfset totalLen = totalLen + lenPhone1 />
					<cfset totalMatches = totalMatches + 1 />
					<cfset phoneInPlay = 1 />
				<cfelseif distancePhone2 lt distancePhone1>
					<cfset totalDistance = totalDistance + distancePhone2 />
					<cfset totalLen = totalLen + lenPhone2 />
					<cfset totalMatches = totalMatches + 1 />
					<cfset phoneInPlay = 2 />
				</cfif>
			</cfif>
			<cfif fieldStruct["Email"].length gt 0>
				<cfset totalDistance = totalDistance + distanceEmail />
				<cfset totalLen = totalLen + lenEmail />
				<cfset totalMatches = totalMatches + 1 />
			</cfif>
			<cfif fieldStruct["DOB"].length gt 0>
				<cfset totalDistance = totalDistance + distanceDOB />
				<cfset totalLen = totalLen + lenDOB />
				<cfset totalMatches = totalMatches + 1 />
			</cfif>
			<cfif fieldStruct["SSN"].length gt 0>
				<cfset totalDistance = totalDistance + fieldStruct["SSN"].distance />
				<cfset totalLen = totalLen + lenSSN />
				<cfset totalMatches = totalMatches + 1 />
			</cfif> --->
	<!--- <address>
		#base.titleCase(Student_First_Name)# #base.titleCase(Student_Last_Name)#<br />
		#base.titleCase(Student_Address)#<br />
		#base.titleCase(Student_City)#, CA #Student_Zip_Code#<br />
		<!--- <cfif phoneInPlay eq 1>#base.formatPhone(Student_Phone1)#<cfelseif phoneInPlay eq 2>#base.formatPhone(Student_Phone2)#</cfif><br /> --->
		<cfif fieldStruct["xxxxx"].lengthPhone1 gt 0 and fieldStruct["xxxx"].distancePhone1 eq 0>
			<td colspan="2" class="success">
				#base.formatPhone(Student_Phone1)#
			</div>
		<cfelseif fieldStruct["xxxxx"].lengthPhone1 gt 0 and fieldStruct["xxxx"].distancePhone1 gt 0>
			<td colspan="2" class="error">
				#base.formatPhone(Student_Phone1)#
			</div>
		<cfelseif fieldStruct["xxxxx"].lengthPhone1 eq 0>
			<td colspan="2" class="info">
				No student home phone
			</div>
		</cfif>
		<cfif fieldStruct["xxxxx"].lengthPhone2 gt 0 and fieldStruct["xxxx"].distancePhone2 eq 0>
			<td colspan="2" class="success">
				#base.formatPhone(Student_Phone2)#
			</div>
		<cfelseif fieldStruct["xxxxx"].lengthPhone2 gt 0 and fieldStruct["xxxx"].distancePhone2 gt 0>
			<td colspan="2" class="error">
				#base.formatPhone(Student_Phone2)#
			</div>
		<cfelseif fieldStruct["xxxxx"].lengthPhone2 eq 0>
			<td colspan="2" class="info">
				No student cell phone
			</div>
		</cfif>
		<cfif fieldStruct["Email"].length gt 0 and fieldStruct["Email"].distance eq 0>
			<td colspan="2" class="success">
				#Student_Email#
			</div>
		<cfelseif fieldStruct["Email"].length gt 0 and fieldStruct["Email"].distance gt 0>
			<td colspan="2" class="error">
				#Student_Email#
			</div>
		<cfelseif fieldStruct["Email"].length eq 0>
			<td colspan="2" class="info">
				No student email
			</div>
		</cfif>
		<cfif fieldStruct["DOB"].length gt 0 and fieldStruct["DOB"].distance eq 0>
			<td colspan="2" class="success">
				#Student_DOB#
			</div>
		<cfelseif fieldStruct["DOB"].length gt 0 and fieldStruct["DOB"].distance gt 0>
			<td colspan="2" class="error">
				#Student_DOB#
			</div>
		<cfelseif fieldStruct["DOB"].length eq 0>
			<td colspan="2" class="info">
				No student DOB
			</div>
		</cfif>
		<cfif fieldStruct["SSN"].length gt 0>
			<cfset validSSN = Len(Student_SSN) eq 4 />
			<cfif validSSN>
				<cfif fieldStruct["SSN"].distance eq 0>
					<td colspan="2" class="success">
						<span class="muted">XXX-XX-</span>#Student_SSN#
					</div>
				<cfelse>
					<td colspan="2" class="error">
						<span class="muted">XXX-XX-</span>#Student_SSN#
					</div>
				</cfif>
			<cfelse>
				<cfif fieldStruct["SSN"].distance eq 0>
					<div class="alert alert-info">
						<span class="muted">XXX-XX-</span>#Student_SSN#
					</div>
				<cfelse>
					<td colspan="2" class="error">
						<span class="muted">XXX-XX-</span>#Student_SSN#
					</div>
				</cfif>
			</cfif>
		<cfelseif fieldStruct["SSN"].length eq 0>
			<td colspan="2" class="info">
				No student SSN
			</div>
		</cfif>
	</address> --->
	<!--- <table class="table table-bordered table-condensed">
		<tr class="rec-row">
			<td class="width50">
				<cfif fieldStruct["xxxxx"].lengthFirstName gt 0 and fieldStruct["xxxx"].distanceFirstName eq 0>
					<td colspan="2" class="success">
						#base.titleCase(Student_First_Name)#
					</div>
				<cfelseif fieldStruct["xxxxx"].lengthFirstName gt 0 and fieldStruct["xxxx"].distanceFirstName gt 0>
					<td colspan="2" class="error">
						#base.titleCase(Student_First_Name)#
					</div>
				<cfelseif fieldStruct["xxxxx"].lengthFirstName eq 0>
					<td colspan="2" class="info">
						No data
					</div>
				</cfif>
			</td>
			<td class="width50">
				<cfif fieldStruct["xxxxx"].lengthLastName gt 0 and fieldStruct["xxxx"].distanceLastName eq 0>
					<td colspan="2" class="success">
						#base.titleCase(Student_Last_Name)#
					</div>
				<cfelseif fieldStruct["xxxxx"].lengthLastName gt 0 and fieldStruct["xxxx"].distanceLastName gt 0>
					<td colspan="2" class="error">
						#base.titleCase(Student_Last_Name)#
					</div>
				<cfelseif fieldStruct["xxxxx"].lengthLastName eq 0>
					<td colspan="2" class="info">
						No data
					</div>
				</cfif>
			</td>
		</tr>
		<tr class="rec-row">
			<td colspan="2" class="width100">
				<cfif fieldStruct["xxxxx"].lengthAddress gt 0 and fieldStruct["xxxx"].distanceAddress eq 0>
					<td colspan="2" class="success">
						#base.titleCase(Student_Address)#
					</div>
				<cfelseif fieldStruct["xxxxx"].lengthAddress gt 0 and fieldStruct["xxxx"].distanceAddress gt 0>
					<td colspan="2" class="error">
						#base.titleCase(Student_Address)#
					</div>
				<cfelseif fieldStruct["xxxxx"].lengthAddress eq 0>
					<td colspan="2" class="info">
						No data
					</div>
				</cfif>
			</td>
		</tr>
		<tr class="rec-row">
			<td >
				<cfif fieldStruct["xxxxx"].lengthCity gt 0 and fieldStruct["xxxx"].distanceCity eq 0>
					<td colspan="2" class="success">
						#base.titleCase(Student_City)#
					</div>
				<cfelseif fieldStruct["xxxxx"].lengthCity gt 0 and fieldStruct["xxxx"].distanceCity gt 0>
					<td colspan="2" class="error">
						#base.titleCase(Student_City)#
					</div>
				<cfelseif fieldStruct["xxxxx"].lengthCity eq 0>
					<td colspan="2" class="info">
						No data
					</div>
				</cfif>
			</td>
			<td class="width30">
				<cfif fieldStruct["xxxxx"].lengthZipCode gt 0 and fieldStruct["xxxx"].distanceZipCode eq 0>
					<td colspan="2" class="success">
						#Student_Zip_Code#
					</div>
				<cfelseif fieldStruct["xxxxx"].lengthZipCode gt 0 and fieldStruct["xxxx"].distanceZipCode gt 0>
					<td colspan="2" class="error">
						#Student_Zip_Code#
					</div>
				<cfelseif fieldStruct["xxxxx"].lengthZipCode eq 0>
					<td colspan="2" class="info">
						No data
					</div>
				</cfif>
			</td>
		</tr>
		<tr class="rec-row">
			<td colspan="2" class="width100">
				<cfif fieldStruct["xxxxx"].lengthPhone1 gt 0 and fieldStruct["xxxx"].distancePhone1 eq 0>
					<td colspan="2" class="success">
						#base.formatPhone(Student_Phone1)#
					</div>
				<cfelseif fieldStruct["xxxxx"].lengthPhone1 gt 0 and fieldStruct["xxxx"].distancePhone1 gt 0>
					<td colspan="2" class="error">
						#base.formatPhone(Student_Phone1)#
					</div>
				<cfelseif fieldStruct["xxxxx"].lengthPhone1 eq 0>
					<td colspan="2" class="info">
						No data
					</div>
				</cfif>
			</td>
		</tr>
		<tr class="rec-row">
			<td colspan="2" class="width100">
				<cfif fieldStruct["xxxxx"].lengthPhone2 gt 0 and fieldStruct["xxxx"].distancePhone2 eq 0>
					<td colspan="2" class="success">
						#base.formatPhone(Student_Phone2)#
					</div>
				<cfelseif fieldStruct["xxxxx"].lengthPhone2 gt 0 and fieldStruct["xxxx"].distancePhone2 gt 0>
					<td colspan="2" class="error">
						#base.formatPhone(Student_Phone2)#
					</div>
				<cfelseif fieldStruct["xxxxx"].lengthPhone2 eq 0>
					<td colspan="2" class="info">
						No data
					</div>
				</cfif>
			</td>
		</tr>
		<tr class="rec-row">
			<td colspan="2" class="width100">
				<cfif fieldStruct["Email"].length gt 0 and fieldStruct["Email"].distance eq 0>
					<td colspan="2" class="success">
						#Student_Email#
					</div>
				<cfelseif fieldStruct["Email"].length gt 0 and fieldStruct["Email"].distance gt 0>
					<td colspan="2" class="error">
						#Student_Email#
					</div>
				<cfelseif fieldStruct["Email"].length eq 0>
					<td colspan="2" class="info">
						No data
					</div>
				</cfif>
			</td>
		</tr>
		<tr class="rec-row">
			<td colspan="2" class="width100">
				<cfif fieldStruct["DOB"].length gt 0 and fieldStruct["DOB"].distance eq 0>
					<td colspan="2" class="success">
						#Student_DOB#
					</div>
				<cfelseif fieldStruct["DOB"].length gt 0 and fieldStruct["DOB"].distance gt 0>
					<td colspan="2" class="error">
						#Student_DOB#
					</div>
				<cfelseif fieldStruct["DOB"].length eq 0>
					<td colspan="2" class="info">
						No data
					</div>
				</cfif>
			</td>
		</tr>
		<tr class="rec-row">
			<td colspan="2" class="width100">
				<cfif fieldStruct["SSN"].length gt 0>
					<cfset validSSN = Len(Student_SSN) eq 4 />
					<cfif validSSN>
						<cfif fieldStruct["SSN"].distance eq 0>
							<td colspan="2" class="success">
								<span class="ssn-muted">######-####-</span>#Student_SSN#
							</div>
						<cfelse>
							<td colspan="2" class="error">
								<span class="ssn-muted">######-####-</span>#Student_SSN#
							</div>
						</cfif>
					<cfelse>
						<cfif fieldStruct["SSN"].distance eq 0>
							<div class="alert alert-info">
								<span class="ssn-muted">######-####-</span>#Student_SSN#
							</div>
						<cfelse>
							<td colspan="2" class="error">
								<span class="ssn-muted">######-####-</span>#Student_SSN#
							</div>
						</cfif>
					</cfif>
				<cfelseif fieldStruct["SSN"].length eq 0>
					<td colspan="2" class="info">
						No data
					</div>
				</cfif>
			</td>
		</tr>
	</table>

Calculate aggregate scores for all fields in record, this was moved to GDSGateway as function "score"
<cfset totalStruct = StructNew() />
<cfset totalStruct.GDS_ID = GDS_ID />
<cfset totalStruct.Student_ID = Student_ID />
<cfset totalStruct.count = 0 />
<cfset totalStruct.length = 0 />
<cfset totalStruct.exclusions = 0 />
<cfset totalStruct.distance = 0 />
<cfset totalStruct.matches = 0 />
<cfset totalStruct.score = 0 />
<cfset totalStruct.bonusPoints = 0 />
<cfset totalStruct.netScore = 0 />
<cfset totalStruct.phone = "" />
<cfset fieldStruct = StructNew() />
<cfloop index="f" list="#configStruct.fieldList#">
	<cfset fieldStruct[f] = StructNew() />
	<cfset fieldStruct[f].length = gds["length" & f][CurrentRow] />
	<!--- value in both fields --->
	<cfif fieldStruct[f].length gt 0>
		<cfset fieldStruct[f].distance = gds["distance" & f][CurrentRow] />
		<cfset fieldStruct[f].exclude = 0 />
		<cfif fieldStruct[f].distance eq 0>
			<cfset fieldStruct[f].match = 1 />
		<cfelse>
			<cfset fieldStruct[f].match = 0 />
		</cfif>
		<cfset fieldStruct[f].score = ((fieldStruct[f].length - fieldStruct[f].distance) / fieldStruct[f].length) * 100 />
		<!--- bonuses for perfect matches --->
		<cfif ListFind(configStruct.bonusFields, f) gt 0>
			<cfset fieldStruct[f].bonusPoints = 1 />
		<cfelseif ListFind(configStruct.doubleBonusFields, f) gt 0>
			<cfset fieldStruct[f].bonusPoints = 2 />
		<cfelseif ListFind(configStruct.tripleBonusFields, f) gt 0>
			<cfset fieldStruct[f].bonusPoints = 3 />
		<cfelse>
			<cfset fieldStruct[f].bonusPoints = 0 />
		</cfif>
		<cfset fieldStruct[f].netScore = fieldStruct[f].score + fieldStruct[f].bonusPoints />
	<!--- no value in one or the other field --->	
	<cfelse>
		<cfset fieldStruct[f].distance = 0 />
		<cfset fieldStruct[f].exclude = 1 />
		<cfset fieldStruct[f].match = 0 />
		<cfset fieldStruct[f].score = 0 />
		<cfset fieldStruct[f].bonusPoints = 0 />
		<cfset fieldStruct[f].netScore = 0 />
	</cfif>
	<!--- update totalStruct --->
	<cfset totalStruct.count = totalStruct.count + 1 />
	<cfif fieldStruct[f].exclude eq 0>
		<cfset totalStruct.length = totalStruct.length + fieldStruct[f].length />
		<cfset totalStruct.distance = totalStruct.distance + fieldStruct[f].distance />
		<cfset totalStruct.matches = totalStruct.matches + fieldStruct[f].match />
		<cfset totalStruct.bonusPoints = totalStruct.bonusPoints + fieldStruct[f].bonusPoints />
	<cfelse>
		<cfset totalStruct.exclusions = totalStruct.exclusions + 1 />	
	</cfif>		
</cfloop>
<!--- post process totalStruct issue with having 1 GDS phone and 2 exit survey phones --->
<cfif fieldStruct["Phone1"].score gt fieldStruct["Phone2"].score>
	<cfset totalStruct.phone = "Home" />
	<cfset totalStruct.length = totalStruct.length - fieldStruct["Phone2"].length />
	<cfset totalStruct.distance = totalStruct.distance - fieldStruct["Phone2"].distance />
	<cfif fieldStruct["Phone2"].match eq 1>
		<cfset totalStruct.matches = totalStruct.matches - 1 />
	</cfif>
	<cfif fieldStruct["Phone2"].exclude eq 1>
		<cfset totalStruct.exclusions = totalStruct.exclusions - 1 />
	</cfif>
	<cfif fieldStruct["Phone2"].bonusPoints gt 0>
		<cfset totalStruct.bonusPoints = totalStruct.bonusPoints - fieldStruct["Phone2"].bonusPoints />
	</cfif>
	<cfset totalStruct.count = totalStruct.count - 1 />
<cfelse>
	<cfset totalStruct.phone = "Cell" />
	<cfset totalStruct.length = totalStruct.length - fieldStruct["Phone1"].length />
	<cfset totalStruct.distance = totalStruct.distance - fieldStruct["Phone1"].distance />
	<cfif fieldStruct["Phone1"].match eq 1>
		<cfset totalStruct.matches = totalStruct.matches - 1 />
	</cfif>
	<cfif fieldStruct["Phone1"].exclude eq 1>
		<cfset totalStruct.exclusions = totalStruct.exclusions - 1 />
	</cfif>
	<cfif fieldStruct["Phone1"].bonusPoints gt 0>
		<cfset totalStruct.bonusPoints = totalStruct.bonusPoints - fieldStruct["Phone1"].bonusPoints />
	</cfif>
	<cfset totalStruct.count = totalStruct.count - 1 />
</cfif>
<cfset totalStruct.score = ((totalStruct.length - totalStruct.distance) / totalStruct.length) * 100 />
<cfset totalStruct.netScore = totalStruct.score + totalStruct.bonusPoints />

Another series
<div class="container-fluid">
	<cfloop query="gds">
		<cfscript>
			// GDS
			gdsStruct = structNew();
			//gdsStruct.Student_ID = Student_ID;
			gdsStruct.First_Name = Replace(REReplace(UCase(Trim(First_Name)), "[^A-Z\ \-\']", "", "all"), "  ", " ", "all");
			gdsStruct.Last_Name = Replace(REReplace(UCase(Trim(Last_Name)), "[^A-Z\ \-\']", "", "all"), "  ", " ", "all");
			//gdsStruct.Full_Name = gdsStruct.First_Name & " " & gdsStruct.Last_Name;
			gdsStruct.Address = Replace(REReplace(UCase(Trim(Address)), "[^A-Z0-9\ ]", "", "all"), "  ", " ", "all");
			gdsStruct.City = Replace(REReplace(UCase(Trim(City)), "[^A-Z\ ]", "", "all"), "  ", " ", "all");
			gdsStruct.Zip_Code = Left(REReplace(Trim(Zip_Code), "[^0-9]", "", "all"), 5);
			//gdsStruct.Full_Address = gdsStruct.Address & " " & gdsStruct.City & " " & gdsStruct.Zip_Code;
			gdsStruct.Email = REReplace(UCase(Trim(Email)), "[^A-Z0-9\@\.\_\-]", "", "all");
			gdsStruct.SSN = Right(REReplace(Trim(SSN), "[^0-9]", "", "all"), 4);
			// Student
			studentStruct = structNew();
			//studentStruct.Student_ID = Student_ID;
			studentStruct.First_Name = Replace(REReplace(UCase(Trim(Student_First_Name)), "[^A-Z\ \-\']", "", "all"), "  ", " ", "all");
			studentStruct.Last_Name = Replace(REReplace(UCase(Trim(Student_Last_Name)), "[^A-Z\ \-\']", "", "all"), "  ", " ", "all");
			//studentStruct.Full_Name = studentStruct.First_Name & " " & studentStruct.Last_Name;
			studentStruct.Address = Replace(REReplace(UCase(Trim(Student_Address)), "[^A-Z0-9\ ]", "", "all"), "  ", " ", "all");
			studentStruct.City = Replace(REReplace(UCase(Trim(Student_City)), "[^A-Z\ ]", "", "all"), "  ", " ", "all");
			studentStruct.Zip_Code = Left(REReplace(Trim(Student_Zip_Code), "[^0-9]", "", "all"), 5);
			//studentStruct.Full_Address = studentStruct.Address & " " & studentStruct.City & " " & studentStruct.Zip_Code;
			studentStruct.Email = REReplace(UCase(Trim(Student_Email)), "[^A-Z0-9\@\.\_\-]", "", "all");
			studentStruct.SSN = Right(REReplace(Trim(Student_SSN), "[^0-9]", "", "all"), 4);
			if (isDate(DOB)) {
				gdsStruct.DOB = DateFormat(DOB, "mm/dd/yyyy");
			} else {
				gdsStruct.DOB = "";
			}
			if (isDate(Student_DOB)) {
				studentStruct.DOB = DateFormat(Student_DOB, "mm/dd/yyyy");
			} else {
				studentStruct.DOB = "";
			}
			gdsStruct.Phone = REReplace(Trim(Phone), "[^0-9]", "", "all");
			usePhone = base.pickPhone(Phone, Student_Phone1, Student_Phone2);
			if (usePhone eq "phone1") {
				studentStruct.Phone = REReplace(Trim(Student_Phone1), "[^0-9]", "", "all");
			} else {
				studentStruct.Phone = REReplace(Trim(Student_Phone2), "[^0-9]", "", "all");
			}
			// Do the comparison! struct1 is GDS, struct2 is Student
			//compareResult = base.compareStructs(gdsStruct, studentStruct);
			compareResult = base.scoreStructs(gdsStruct, studentStruct);
			// create pointer variables for brevity of code
			result = compareResult.result;
			gds = compareResult.struct1;
			student = compareResult.struct2;
			config = compareResult.config;
			/* 
				GDS has one phone, Student has two.
				The comparison created properties for both combinations: GDS.Phone vs Student.Phone1 and GDS.Phone vs Student.Phone2.
				Keep the best match score, eliminate the other from scoring.
				
				- if Phone2 score is equal to or better than Phone1, create a Phone property and set it to result for Phone2
				- otherwise create Phone property and set it to result of Phone1
				- delete Phone1 and Phone2 properties (in all 4 structs) so they aren't scored down the line
			*/
			try {
				perfectDiscount = compareResult.perfect * .025;
				bonusDiscount = compareResult.bonus * .025;
				totalBonus = perfectDiscount + bonusDiscount;
				matchThreshold = .7 - totalBonus;
				unmatchThreshold = .5;
			}
			catch(any err) {
				writeDump(err);
				writeDump(var = compareResult, expand = "no");
			}
		</cfscript>
		<cfif 	(client.gds.proposalValue eq "Match" and compareResult.score gte matchThreshold)
				or (client.gds.proposalValue eq "Unmatch" and compareResult.score lte unmatchThreshold)
				or (client.gds.proposalValue eq "Review" and compareResult.score gt unmatchThreshold and compareResult.score lt matchThreshold)>
			<cfoutput>
				<div id="gdsMatch_#GDS_ID#" class="row">
					<div class="span2">
						<h4>Student</h4>
						<div class="rec-box">
							<span class="highlighted">
								#result.first_name.string2#<br />
								#result.last_name.string2#<br />
								#result.address.string2#<br />
								#result.city.string2#<br />
								#result.zip_code.string2#<br />
								#result.email.string2#<br />
								#result.phone.string2#<br />
								#result.dob.string2#<br />
								#result.ssn.string2#
							</span>
						</div>
						<p>Student ID: #Student_ID#</p>
					</div>
					<div class="span2">
						<h4>GDS</h4>
						<div class="rec-box">
							<span class="highlighted">
								#result.first_name.string1#<br />
								#result.last_name.string1#<br />
								#result.address.string1#<br />
								#result.city.string1#<br />
								#result.zip_code.string1#<br />
								#result.email.string1#<br />
								#result.phone.string1#<br />
								#result.dob.string1#<br />
								#result.ssn.string1#
							</span>
						</div>
						<p>GDS ID: #GDS_ID#</p>
					</div>
					<div class="span4">
						<table class="table table-bordered score-table">
							<!--- <tr>
								<th>Similarity</th>
								<td>#DecimalFormat(compareResult.similarity)#</td>
							</tr>
							<tr>
								<th>Commonality</th>
								<td>#DecimalFormat(compareResult.commonality)#</td>
							<tr>
								<th>Continuity</th>
								<td>#DecimalFormat(compareResult.continuity)#</td>
							</tr>
							<tr>
								<th>Score</th>
								<td>#DecimalFormat(compareResult.score)#</td>
							</tr>
							<tr>
								<th>Bonus/Penalty</th>
								<td>+#totalBonus#</td>
							</tr> --->
							<tr>
								<th>Verification Action</th>
								<td>#client.gds.proposalValue#</td>
							</tr>
							<tr>
								<td colspan="2">
									<cfif compareResult.score gte matchThreshold>
										<a href="##" class="btn btn-danger btn-block" onclick="confirmUnmatch(#GDS_ID#); return false;">Unmatch</a>
									<cfelseif compareResult.score lte unmatchThreshold>
										<a href="##" class="btn btn-success btn-block" onclick="unmatchGDS(#GDS_ID#); return false;">Unmatch</a>
									<cfelse>
										<a href="##" class="btn btn-warning btn-block" onclick="confirmUnmatch(#GDS_ID#); return false;">Unmatch</a>
									</cfif>
								</td>
							</tr>
						</table>
					</div>
					<div class="span4">
						<cfset finalScore = (compareResult.score + totalBonus) * 100 />
						<h1>#DecimalFormat(finalScore)#</h1>
						<!--- <table class="table table-bordered table-striped table-condensed stat-table">
							<thead>
								<tr>
									<th width="40%">Field</th>
									<th width="15%">Similarity</th>
									<th width="15%">Commonality</th>
									<th width="15%">Continuity</th>
									<th width="15%">Score</th>
								</tr>
							</thead>
							<tbody>
								<cfset fields = StructKeyList(result) />
								<cfset fields = ListSort(fields, "TextNoCase") />
								<cfloop index="prop" list="#fields#">
									<tr>
										<td>#prop#</td>
										<td>#DecimalFormat(result[prop].similarity)#</td>
										<td>#DecimalFormat(result[prop].commonality)#</td>
										<td>#DecimalFormat(result[prop].continuity)#</td>
										<td>#DecimalFormat(result[prop].score)#%</td>
									</tr>
								</cfloop>
							</tbody>
						</table> --->
					</div>
				</div>
			</cfoutput>
			<cfset displayedCount = displayedCount + 1 />
		</cfif>
	</cfloop>
</div>

Yet another
<cfloop index="prop" list="#propList#">
	<cfif IsStruct(compareResult.result[prop])>
		<cfif fieldStruct["xxxxx"].length(compareResult.result[prop].string1) gt 0 and Len(compareResult.result[prop].string2) gt 0>
			<cfset totalScore = totalScore + compareResult.result[prop].score />
			<cfset maxScore = maxScore + 1 />
			<cfset pct = compareResult.result[prop].score * 100 />
			<cfset totalMultipliers = totalMultipliers + compareResult.config[prop].multiplier />
			<cfset weightedScore = compareResult.result[prop].score * compareResult.config[prop].multiplier />
			<cfset totalWeightedScore = totalWeightedScore + weightedScore />
			<cfset maxWeightedScore = maxWeightedScore + compareResult.config[prop].multiplier />
			<cfset weightedPCT = weightedScore/compareResult.config[prop].multiplier * 100 />
			<cfset totalOffsets = totalOffsets + compareResult.config[prop].maxOffset />
			<cfset totalLCS = totalLCS + compareResult.result[prop].lcs/>
			<cfset totalDistance = totalDistance + compareResult.result[prop].distance />
			<cfif pct eq 100>
				<cfset perfectScores = perfectScores + 1>
			</cfif>
			<cfset scoreCount = scoreCount + 1 />
		</cfif>
		<tr>
			<td>
				#compareResult.result.first_name.string1# #compareResult.result.last_name.string1#<br />
				#compareResult.result.address.string1#<br />
				#compareResult.result.city.string1#, CA #compareResult.result.zip_code.string1#<br />
				#compareResult.result.email.string1#<br />
				#compareResult.result.dob.string1#<br />
				#compareResult.result.ssn.string1#
			</td>
			<td>
				#compareResult.result.first_name.string2# #compareResult.result.last_name.string2#<br />
				#compareResult.result.address.string2#<br />
				#compareResult.result.city.string2#, CA #compareResult.result.zip_code.string2#<br />
				#compareResult.result.email.string2#<br />
				#compareResult.result.dob.string2#<br />
				#compareResult.result.ssn.string2#
			</td>
			<td>
				<h2>Score</h2>
				<a href="?action=rejectGDS&view=#view#&GDS_ID=#GDS_ID#" class="btn btn-warning">Unmatch</a>
			</td>
			<cfif showStats>
				<td>
					<table>
						<tr>
							<th class="statcol">Property</th>
							<th class="statcol">Score</th>
							<th class="statcol">Max Offset</th>
							<th class="statcol">LCS</th>
							<th class="statcol">Distance</th>
						</tr>
						<tr>
							<td>#prop#</td>
							<cfif fieldStruct["xxxxx"].length(compareResult.result[prop].string1) gt 0 and Len(compareResult.result[prop].string2) gt 0>
								<td>#compareResult.result[prop].score#</td>
								<td>#Int(compareResult.config[prop].maxOffset)#</td>
								<td>#Int(compareResult.result[prop].lcs)#</td>
								<td>#Int(compareResult.result[prop].distance)#</td>
							<cfelse>
								<td colspan="4" style="text-align: center;">N/A</td>
							</cfif>
						</tr>
					</table>
				</td>
			</cfif>
		</tr>
	</cfif>
</cfloop>

 --->